<template>
	<!-- @getphonenumber -->
	 <button @getphonenumber="getphonenumber" open-type="getPhoneNumber" type="primary" >登录</button>
	 <button @click="change">
		 登录
	 </button>
	 

	<button type="success" @click="turnAdd">添加就诊人</button>
	 
	  <button  type="primary"  @click="toPhy">我的体检</button>
	 
</template>

<script>
	// appid:"wxa0f1a106300076a2"
	// secret:"87df0c50c452e0f4b786220bb4eb7e37"
	
	// nickName:user.userInfo.nickName,
	// avatarUrl:user.userInfo.avatarUrl
	//code:res.code  //微信官方的登录凭证  uni.login()  getPhoneNumber
// getUserinfo
import {toLoginApi} from '@/api/home.js'
	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
		onLoad() {
              uni.getSetting({
              	success(res){
					console.log(res,"授权列表")
				}
              })
		},
		methods: {
			toPhy(){
				uni.navigateTo({ //去到我的体检预约记录
					url:"/pages/myphy/index"
				})
			},
			turnAdd(){ //跳转添加就诊人
				uni.navigateTo({
					url:'/pages/addperson/index'
				})
			},
			getphonenumber(e){
				console.log(e,"----------")
				// uni.login()
			},
			change(){
				uni.login({
					success(loginres){
						uni.getUserInfo({
							success:async (res)=>{
								let loginData=await toLoginApi({
									appid:"wxa0f1a106300076a2",
									secret:"87df0c50c452e0f4b786220bb4eb7e37",
									nickName:res.userInfo.nickName,
									avatarUrl:res.userInfo.avatarUrl,
									code:loginres.code
								})
								console.log(loginData,"---------啥地方")
								uni.setStorageSync("token",loginData.data.user_Token)
							}
						})
					}
				})
				
			}
		}
	}
	
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
